//
//  QuizSubmitListCell.m
//  SubmitVCDemo
//
//  Created by Tianlong on 2018/1/25.
//  Copyright © 2018年 Tianlong. All rights reserved.
//

#import "QuizSubmitListCell.h"
#import "QuizSubmitTopView.h"
#import "QuizAnalyView.h"
#import "QuizScoreView.h"
#import "QuizTalkView.h"

@interface QuizSubmitListCell ()
@property (weak, nonatomic) UITableView *tableView;
// 名次
@property (weak, nonatomic) IBOutlet UIButton *rankBtn;
// 头像
@property (weak, nonatomic) IBOutlet UIImageView *iconV;
// 姓名
@property (weak, nonatomic) IBOutlet UILabel *nameL;
// 分数
@property (weak, nonatomic) IBOutlet UILabel *scoreL;
// 时间
@property (weak, nonatomic) IBOutlet UILabel *timeL;

// 名字到分数的间距
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *nameToScoreM;
// 分数到时间的间距
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *scoreToTimeM;

@end

@implementation QuizSubmitListCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    // 该标识xib也有设置
    static NSString *cellId = @"QuizSubmitListCell";
    QuizSubmitListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if(!cell){
        cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([QuizSubmitListCell class]) owner:self options:nil] lastObject];
    }
    cell.tableView = tableView;
    return cell;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    if([UIScreen mainScreen].bounds.size.width==320){
        self.nameToScoreM.constant = 15;
        self.scoreToTimeM.constant = 8;
    }
}

- (void)setItem:(QuizSubmitListItem *)item{
    _item = item;
    self.nameL.text = item.name.length>0?item.name:@"";
    self.timeL.text = item.time.length>0?item.time:@"";
    self.scoreL.text = item.score.length>0?item.score:@"";
    [self.rankBtn setTitle:item.rank.length>0?item.rank:@"" forState:UIControlStateNormal];
}




@end
